package com.example.transaction.service;

import com.example.transaction.model.Account;

import java.math.BigDecimal;
import java.util.List;

public interface AccountService {
    
    // 创建新账户
    Account createAccount(String accountNumber, String ownerName, BigDecimal initialBalance);
    
    // 获取账户信息
    Account getAccount(String accountNumber);
    
    // 获取所有账户
    List<Account> getAllAccounts();
    
    // 存款操作
    Account deposit(String accountNumber, BigDecimal amount);
    
    // 取款操作
    Account withdraw(String accountNumber, BigDecimal amount);
    
    // 转账操作 - 最外层事务
    void transfer(String fromAccountNumber, String toAccountNumber, BigDecimal amount);
    
    // 批量转账 - 演示嵌套事务
    void batchTransfer(List<TransferRequest> transfers);
    
    // 转账请求数据类
    class TransferRequest {
        private String fromAccountNumber;
        private String toAccountNumber;
        private BigDecimal amount;
        
        public TransferRequest(String fromAccountNumber, String toAccountNumber, BigDecimal amount) {
            this.fromAccountNumber = fromAccountNumber;
            this.toAccountNumber = toAccountNumber;
            this.amount = amount;
        }
        
        public String getFromAccountNumber() {
            return fromAccountNumber;
        }
        
        public String getToAccountNumber() {
            return toAccountNumber;
        }
        
        public BigDecimal getAmount() {
            return amount;
        }
    }
}